import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Vuesax from 'vuesax'
import Antd from 'ant-design-vue'
import 'vuesax/dist/vuesax.css'
import 'boxicons'
import 'boxicons/css/boxicons.min.css'
import * as echarts from 'echarts'
import VueMarkdownEditor from '@kangc/v-md-editor'
import '@kangc/v-md-editor/lib/style/base-editor.css'
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js'
import '@kangc/v-md-editor/lib/theme/style/vuepress.css'
import Prism from 'prismjs'
import createEmojiPlugin from '@kangc/v-md-editor/lib/plugins/emoji/index'
import '@kangc/v-md-editor/lib/plugins/emoji/emoji.css'
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index'
import createHighlightLinesPlugin from '@kangc/v-md-editor/lib/plugins/highlight-lines/index'
import '@kangc/v-md-editor/lib/plugins/highlight-lines/highlight-lines.css'
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index'
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css'
import Chat from 'vue-beautiful-chat'
Vue.prototype.$echarts = echarts
VueMarkdownEditor.use(vuepressTheme, {
  Prism
})
VueMarkdownEditor.use(createEmojiPlugin())
VueMarkdownEditor.use(createLineNumbertPlugin())
VueMarkdownEditor.use(createHighlightLinesPlugin())
VueMarkdownEditor.use(createCopyCodePlugin())
console.log(`
 ████     ████          ██████    ██
░██░██   ██░██  ██   ██░█░░░░██  ░██           █████   █████
░██░░██ ██ ░██ ░░██ ██ ░█   ░██  ░██  ██████  ██░░░██ ██░░░██  █████  ██████
░██ ░░███  ░██  ░░███  ░██████   ░██ ██░░░░██░██  ░██░██  ░██ ██░░░██░░██░░█
░██  ░░█   ░██   ░██   ░█░░░░ ██ ░██░██   ░██░░██████░░██████░███████ ░██ ░
░██   ░    ░██   ██    ░█    ░██ ░██░██   ░██ ░░░░░██ ░░░░░██░██░░░░  ░██
░██        ░██  ██     ░███████  ███░░██████   █████   █████ ░░██████░███
░░         ░░  ░░      ░░░░░░░  ░░░  ░░░░░░   ░░░░░   ░░░░░   ░░░░░░ ░░░


For geeks who wanted to write their blog site in Vue                 v2.1.1

Powered by %cMyBlogger%cv2.1.1%c

GitHub: https://gitee.com/DuanQingStudy\n
我的目标:所见所闻即为博客内容~~~~~~~~~~~~~~~~~~~~~~~~`,

'background-color: #1A55ED; padding: 7px; color: #fff;',
'background-color: #FCBF23; color: #000; padding: 7px;',
'font-weight: bold')

Vue.config.productionTip = false

Vue.use(Vuesax, {})
Vue.use(Antd)
Vue.use(VueMarkdownEditor)
Vue.use(Chat)
Vue.mixin({
  methods: {
    changeTitle: function (title) {
      let Config = null
      try {
        Config = require('@/../posts/data/config.json')
      } catch (e) {
        Config = require('@/defaults/config.json')
      }
      document.title = `${title} - ${Config.config.blogTitle}`
    },
    getConfig: function (name = 'config.json') {
      let Config = null
      try {
        Config = require(`@/../posts/data/${name}`)
      } catch (e) {
        Config = require(`@/defaults/${name}`)
      }
      return Config
    }
  },
  computed: {
    tags: function () {
      let Posts = null
      try {
        Posts = require('@/../posts/data/posts.json')
      } catch (e) {
        Posts = require('@/defaults/posts.json')
      }
      const posts = Posts.posts
      const tags = []
      for (var i = 0; i < posts.length; i++) {
        for (var j = 0; j < posts[i].tags.length; j++) {
          let index = -1
          for (var k = 0; k < tags.length; k++) {
            if (tags[k].name === posts[i].tags[j]) {
              index = k
              break
            }
          }
          if (index === -1) {
            tags.push({
              name: posts[i].tags[j],
              posts: [
                posts[i]
              ]
            })
          } else {
            tags[index].posts.push(posts[i])
          }
        }
      }
      return tags
    }
  }
})

router.afterEach((to, from, next) => {
  window.scrollTo(0, 0)
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
